  module.exports = app => {
      
      const {
          router,
          controller,
          config,
          middleware
      } = app;

      const {
          user,
          post,
          upload
      } = controller;

      const userRequired = middleware.userRequired();
      const userNoRequired = middleware.userNorequired();

      // 首页
      router.get('/', post.index);

      // 注册
      router.get('/reg',userNoRequired, user.registerShow);
      router.post('/reg', user.register);

      // 登录
      router.get('/login',userNoRequired, user.loginShow);
      router.post('/login', user.login);
      router.get('/logout', user.logOut);

      //文章详情
      router.get('/detail/:id', post.getDetailsById);

      //搜索
      router.get('/search', post.searchArticle);

      //某某的文章列表
      router.get('/u/:name',userRequired,post.getArticleByUserName);

      //写文章
      router.get('/post',userRequired, post.post);

      // 保存文章
      router.post('/post',userRequired, post.save);

      //更新文章
      router.post('/edit/:id',userRequired, post.update);

      //编辑文章
      router.get('/edit/:id',userRequired, post.edit);

      //删除文章
      router.get('/remove/:id',userRequired, post.remove);

      //上传
      router.get('/upload',userRequired, upload.index);

      router.post('/upload',userRequired, upload.upload);

      //获取验证码图片
      router.get('/captcha', user.getCaptcha);

  };